package com.cmdi.opensite.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cmdi.opensite.entity.Registration;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 报名记录Mapper接口
 */
@Mapper
public interface RegistrationMapper extends BaseMapper<Registration> {
    
    /**
     * 查询用户是否已报名活动
     */
    Registration findByActivityIdAndUserId(@Param("activityId") Long activityId, @Param("userId") Long userId);
    
    /**
     * 查询活动的报名记录列表
     */
    IPage<Registration> selectActivityRegistrations(IPage<Registration> page, @Param("activityId") Long activityId);
    
    /**
     * 查询用户的报名记录列表
     */
    IPage<Registration> selectUserRegistrations(IPage<Registration> page, @Param("userId") Long userId);
    
    /**
     * 查询活动已确认的报名人数
     */
    int countConfirmedRegistrations(Long activityId);
    
    /**
     * 批量更新报名状态
     */
    int batchUpdateStatus(@Param("ids") List<Long> ids, @Param("status") Integer status);
}